package com.zbkj.admin.controller.platform.shop;

import com.github.pagehelper.PageInfo;
import com.zbkj.common.model.shop.EbIndustryCategory;
import com.zbkj.common.request.EbIndustryCategoryRequest;
import com.zbkj.common.result.CommonResult;
import com.zbkj.service.service.EbIndustryCategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Slf4j
@RestController
@RequestMapping("/api/platform/ebIndustryCategory")
@Api(tags = "团购行业分类")
public class PlatformIndustryCategoryController {
    @Resource
    EbIndustryCategoryService ebIndustryCategoryService;

    /**
     * 增加团购店铺
     *
     * @param ebIndustryCategory
     * @return
     */
    @ApiOperation(value = "增加团购店铺")
    @PostMapping(value = "/add")
    public CommonResult<EbIndustryCategory> add(@RequestBody EbIndustryCategory ebIndustryCategory) {
        return CommonResult.success(ebIndustryCategoryService.add(ebIndustryCategory));
    }


    /**
     * 修改团购店铺
     *
     * @param ebIndustryCategory
     * @return
     */
    @ApiOperation(value = "修改团购店铺")
    @PostMapping(value = "/update")
    public CommonResult<EbIndustryCategory> update(@RequestBody EbIndustryCategory ebIndustryCategory) {
        return CommonResult.success(ebIndustryCategoryService.update(ebIndustryCategory));
    }

    /**
     * 查询详情
     *
     * @param id
     * @return
     */
    @ApiOperation(value = "查询详情")
    @GetMapping(value = "/get/{id}")
    public CommonResult<EbIndustryCategory> get(@PathVariable("id") Integer id) {
        return CommonResult.success(ebIndustryCategoryService.getById(id));
    }

    /**
     * 查询列表
     *
     * @return
     */
    @ApiOperation(value = "查询列表")
    @PostMapping(value = "/getList")
    public CommonResult<List<EbIndustryCategory>> getList(@RequestBody EbIndustryCategoryRequest ebIndustryCategoryRequest) {
        return CommonResult.success(ebIndustryCategoryService.findByList(ebIndustryCategoryRequest));
    }


    @ApiOperation(value = "分页查询列表")
    @PostMapping(value = "/getPage")
    public CommonResult<PageInfo<EbIndustryCategory>> getPage(@RequestBody EbIndustryCategoryRequest ebIndustryCategoryRequest) {
        return CommonResult.success(ebIndustryCategoryService.getPage(ebIndustryCategoryRequest));
    }
}